#!/bin/bash

# init delays
s3pic_cntl 0x80 0x04 0x00
s3pic_cntl 0x81 0x04 0x00
s3pic_cntl 0x82 0x04 0x00

# driver on
s3pic_cntl 0x90 0x00 0x80

# PGM asserted
s3pic_cntl 0x90 0x02 0x80

# MCLR deasserted
s3pic_cntl 0x90 0x03 0x80

# init TBLPTR
s3pic_cntl 0x10 0x00 0x0e
s3pic_cntl 0x10 0xf8 0x6e
s3pic_cntl 0x10 0x00 0x0e
s3pic_cntl 0x10 0xf7 0x6e
s3pic_cntl 0x10 0x00 0x0e
s3pic_cntl 0x10 0xf6 0x6e

# write32
s3pic_cntl 0x32 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x20 0x21 0x22 0x23 0x24 0x25 0x26 0x27 0x30 0x31 0x32 0x33 0x34 0x35 0x36 0x37

# NOP with prog delay
s3pic_cntl 0x80 0x04 0x00
s3pic_cntl 0x81 0x6a 0x18
s3pic_cntl 0x82 0x71 0x02
s3pic_cntl 0x10 0x00 0x00
s3pic_cntl 0x80 0x04 0x00
s3pic_cntl 0x81 0x04 0x00
s3pic_cntl 0x82 0x04 0x00

# MCLR asserted
s3pic_cntl 0x90 0x02 0x80

# PGM deasserted
s3pic_cntl 0x90 0x00 0x80

# driver off
s3pic_cntl 0x90 0x00 0x00
